import json
class UserInfo:
    def __init__(self, user_data):
        self.id = user_data.get('id')
        self.name = user_data.get('name')
        self.age = user_data.get('age')
        self.email = user_data.get('email')
        self.address = user_data.get('address')
        self.is_active = user_data.get('is_active')

    def __str__(self):
        return (f"ID: {self.id}, 姓名: {self.name}, 年龄: {self.age}, "
                f"邮箱: {self.email}, 地址: {self.address}, 活跃状态: {'是' if self.is_active else '否'}")

def main():
    # (1) 读取json.txt中的信息
    try:
        with open('json.txt', 'r', encoding='utf-8') as file:
            users_data = json.load(file)
    except FileNotFoundError:
        print("错误: 未找到json.txt文件")
        return
    except json.JSONDecodeError:
        print("错误: json.txt文件格式不正确")
        return

    # (4) 将Json数据中所有的用户信息进行数据封装并存入列表中
    users_list = []
    for user_data in users_data:
        user = UserInfo(user_data)
        users_list.append(user)

    # (5) 遍历列表输出所有的用户信息
    for user in users_list:
        print(user)


if __name__ == "__main__":
    main()